﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace TarreOA.TarreOABLL
{
    public class MessageAwoke 
    {
        private static MessageAwoke msgAwoke;

        private Hashtable shortMsg_Collections = new Hashtable();//存放短信提示
        private Hashtable email_Collections = new Hashtable();//存放邮件提示
        private Hashtable workFlow_Collections = new Hashtable();//存放工作流提示
        private Hashtable inform_Collections = new Hashtable();//存放公告通知提示

        private MessageAwoke() { }

        public static MessageAwoke Instance()
        {
            if(msgAwoke == null)
            {
                msgAwoke = new MessageAwoke();
            }
            return msgAwoke;
        }

        /// <summary>
        /// 将新消息提示加入短信提示队列中
        /// </summary>
        /// <param name="key">可以是用户的登录名</param>
        /// <param name="value">要存放的值</param>
        public void AddToShortMsg(string key, object value)
        {
            if(this.shortMsg_Collections[key] == null)
            {
                List<object> list = new List<object>();
                list.Add(value);
                this.shortMsg_Collections.Add(key, list);
            }
            else
            {
                List<object> list = (List<object>) this.shortMsg_Collections[key];
                list.Add(value);
                this.shortMsg_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将邮件提示加入邮件提示队列中
        /// </summary>
        /// <param name="key">可以是用户的登录名</param>
        /// <param name="value">要存放的值</param>
        public void AddToEmail(string key, object value)
        {
            if(this.email_Collections[key] == null)
            {
                List<object> list = new List<object>();
                list.Add(value);
                this.email_Collections.Add(key, list);
            }
            else
            {
                List<object> list = (List<object>) this.email_Collections[key];
                list.Add(value);
                this.email_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将工作流提示加入工作流提示队列中
        /// </summary>
        /// <param name="key">可以是用户的登录名</param>
        /// <param name="value">要存放的值</param>
        public void AddToWorkFlow(string key, object value)
        {
            if(this.workFlow_Collections[key] == null)
            {
                List<object> list = new List<object>();
                list.Add(value);
                this.workFlow_Collections.Add(key, list);
            }
            else
            {
                List<object> list = (List<object>) this.workFlow_Collections[key];
                list.Add(value);
                this.workFlow_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将公告通知提示加入公告通知提示队列中
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void AddToInform(string key, object value)
        {
            if(this.inform_Collections[key] == null)
            {
                List<object> list = new List<object>();
                list.Add(value);
                this.inform_Collections.Add(key, list);
            }
            else
            {
                List<object> list = (List<object>) this.inform_Collections[key];
                list.Add(value);
                this.inform_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将某条短消息提示从短消息提示队列某一成员中移除
        /// </summary>
        /// <param name="key">短消息提示队列中某一成员</param>
        /// <param name="value">要移除的值</param>
        public void RemoveValueFromKeyForShortMsg(string key, object value)
        {
            if(this.shortMsg_Collections[key] != null)
            {
                List<object> list = (List<object>) this.shortMsg_Collections[key];
                list.Remove(value);
                this.shortMsg_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将短消息提示队列中某一成员移除
        /// </summary>
        /// <param name="key"></param>
        public void RemoveKeyFromShortMsg(string key)
        {
            if(this.shortMsg_Collections[key] != null)
            {
                this.shortMsg_Collections.Remove(key);
            }
        }

        /// <summary>
        /// 将某条邮件提示从邮件提示队列某一成员中移除
        /// </summary>
        /// <param name="key">邮件提示队列中某一成员</param>
        /// <param name="value">要移除的值</param>
        public void RemoveValueFromKeyForEmai(string key, object value)
        {
            if(this.email_Collections[key] != null)
            {
                List<object> list = (List<object>) this.email_Collections[key];
                list.Remove(value);
                this.email_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将邮件提示队列中某一成员移除
        /// </summary>
        /// <param name="key"></param>
        public void RemoveKeyFromEmail(string key)
        {
            if(this.email_Collections[key] != null)
            {
                this.email_Collections.Remove(key);
            }
        }

        /// <summary>
        /// 将某条工作流提示从工作流提示队列中某一成员中移除
        /// </summary>
        /// <param name="key">工作流提示队列中某一成员</param>
        /// <param name="value">要移除的值</param>
        public void RemoveValueFromKeyForWorkFlow(string key, object value)
        {
            if(this.workFlow_Collections[key] != null)
            {
                List<object> list = (List<object>) this.workFlow_Collections[key];
                list.Remove(value);
                this.workFlow_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将工作流提示队列中某一成员移除
        /// </summary>
        /// <param name="key"></param>
        public void RemoveKeyFromWorkFlow(string key)
        {
            if(this.workFlow_Collections[key] != null)
            {
                this.workFlow_Collections.Remove(key);
            }
        }

        /// <summary>
        /// 将某条公告通知提示从公告通知提示队列中某一成员中移除
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void RemoveValueFromKeyForInform(string key, object value)
        {
            if(this.inform_Collections[key] != null)
            {
                List<object> list = (List<object>) this.inform_Collections[key];
                list.Remove(value);
                this.inform_Collections[key] = list;
            }
        }

        /// <summary>
        /// 将公告通知提示队列中某一成员移除
        /// </summary>
        /// <param name="key"></param>
        public void RemoveKeyFromInform(string key)
        {
            if(this.inform_Collections[key] != null)
            {
                inform_Collections.Remove(key);
            }
        }

        /// <summary>
        /// 获取短消息提示队列中某一成员的值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List<object> GetValuesFromKeyForShortMsg(string key)
        {
            return (List<object>) this.shortMsg_Collections[key];
        }

        /// <summary>
        /// 获取邮件提示队列中某一成员的值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List<object> GetValuesFromKeyForEmail(string key)
        {
            return (List<object>) this.email_Collections[key];
        }

        /// <summary>
        /// 获取工作流提示队列中某一成员的值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List<object> GetValuesFromKeyForWorkFlow(string key)
        {
            return (List<object>) this.workFlow_Collections[key];
        }

        /// <summary>
        /// 获取公告提示队列中某一成员
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List<object> GetValuesFromKeyForInform(string key)
        {
            return (List<object>) this.inform_Collections[key];
        }
    }
}
